package com.wlyy.starter.mybatis;

import com.baomidou.mybatisplus.core.conditions.Wrapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.wlyy.starter.mybatis.dto.IdOrgQuery;
import org.apache.ibatis.annotations.Param;

import java.util.Collection;

import static com.baomidou.mybatisplus.core.toolkit.Constants.COLLECTION;
import static com.baomidou.mybatisplus.core.toolkit.Constants.ENTITY;
import static com.baomidou.mybatisplus.core.toolkit.Constants.WRAPPER;

/**
 * mapper 方法扩展类基类
 *
 * @author JQL
 */

public interface BatchMapper<T> extends BaseMapper<T> {

    /**
     * 批量写
     */
    int insertBatch(@Param(COLLECTION) Collection<T> coll);

    /**
     * 新增或修改
     * @param entity
     * @return
     */
    int insertOrUpdate(T entity);

    int insertOrUpdateAll(@Param(COLLECTION) Collection<T> coll);

    T selectByOrgId(@Param(ENTITY) IdOrgQuery idOrg);

    /**
     * 只查询符合条件的一条数据
     *
     * @return
     */
    T selectLimitOne(@Param(WRAPPER) Wrapper<T> queryWrapper);
}
